# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(lottiepro)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
                    ${CMAKE_CURRENT_SOURCE_DIR}/render/drawing
                    )

add_subdirectory(thirdparty)

add_library(lottiepro SHARED napi_init.cpp
                           task_pool/task_pool.cpp
                           datamanager/lottie_config_data.cpp
                           datamanager/lottie_config_data_bridge.cpp
                           datamanager/data_parse.cpp
                           cache/file_cache.cpp
                           cache/generator_key.cpp
                           cache/memory_cache.cpp
                           node/lottie_listener.cpp
                           controller/lottie_handler.cpp
                           controller/lottie_controller_bridge.cpp
                           animator/animator.cpp
                           datamanager/data_manager.cpp
                           common/napi_helper.cpp
                           node/lottie_xcomponent_node.cpp
                           render/lottie_render.cpp
                           render/lottie_render_layer.cpp
                           render/lottie_render_node.cpp
                           node/lottie_manager_map.cpp
                           lottie_custom_task.cpp
                           render/drawing/brush.cpp
                           render/drawing/gly_path_bag.cpp
                           render/drawing/matrix.cpp
                           render/drawing/path.cpp
                           render/drawing/pen.cpp
                           render/drawing/rect.cpp
                           render/drawing/round_rect.cpp
                           render/drawing/shader_effect.cpp
                           render/drawing/color.cpp
                           render/drawing/canvas.cpp
                           render/drawing/bitmap.cpp
                           render/drawing/point.cpp
                           render/drawing/font_mgr.cpp
                           render/drawing/font.cpp
                           render/drawing/text_blob.cpp
                           render/drawing/draw_filter.cpp
                           )

target_link_libraries(lottiepro PUBLIC libace_napi.z.so
                                     libace_ndk.z.so
                                     rlottie::rlottie
                                     libhilog_ndk.z.so
                                     libuv.so
                                     libnative_drawing.so
                                     libpixelmap_ndk.z.so
                                     libimage_source_ndk.z.so
                                     libpixelmap.so
                                     libohresmgr.so
                                     librawfile.z.so
                                     librcp_c.so
                                     libohcrypto.so
                                     libnative_window.so
                                     libffrt.z.so
                                     )
target_compile_options(lottiepro PUBLIC -fvisibility=hidden)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_link_options(lottiepro PUBLIC -s)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
    target_compile_definitions(lottiepro PUBLIC RELEASE_MODE=1)
else()
    target_compile_definitions(lottiepro PUBLIC RELEASE_MODE=0)
    target_link_libraries(lottiepro PUBLIC libhitrace_ndk.z.so)
endif()
if("${OHOS_ARCH}" STREQUAL "arm64-v8a")
    target_link_directories(lottiepro PUBLIC ${HMOS_SDK_NATIVE}/sysroot/usr/lib/aarch64-linux-ohos)
elseif("${OHOS_ARCH}" STREQUAL "armeabi-v7a")
    target_link_directories(lottiepro PUBLIC ${HMOS_SDK_NATIVE}/sysroot/usr/lib/arm-linux-ohos)
elseif("${OHOS_ARCH}" STREQUAL "x86_64")
    target_link_directories(lottiepro PUBLIC ${HMOS_SDK_NATIVE}/sysroot/usr/lib/x86_64-linux-ohos)
endif()

